fix(tests): align SSE and quantum integration tests with current APIs#475
Conversation
Update stream endpoint tests to capture materialized SSE byte bodies from _sse_response and accept min_similarity in fetch_similar_messages mocks. Use whitelisted smoke job name in quantum autorun integration test. Co-authored-by: Bryan
Reviewer's GuideIntroduces a reusable helper for capturing SSE HttpResponse bodies in streaming tests, updates chat stream mocks to match the current fetch_similar_messages signature, and restores the expected smoke job name in quantum integration tests so autorun status checks align with real job configurations. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
🟡 Coverage —
|
| Metric | Value |
|---|---|
| Total coverage | 65.2% |
▲ vs main |
+0.1% |
| Minimum threshold | 60% |
Updated on every push · 2026-06-21
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@Bryan-Roe Thanks for sending me some feedback. Unfortunately, I hit an error while trying to use the custom Copilot setup steps configured for this repository. The error I am seeing is: Once you or someone with the necessary access fixes the problem, please let me know in a comment and I'll try again. Thanks! |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR is a test-only refactoring. It deduplicates repeated SSE response-capturing logic in the Function App endpoint tests into a shared helper, updates a stub lambda to match an extended fetch_similar_messages signature, and renames a quantum integration test job from another to smoke.
Changes:
- Extracted a reusable
_capture_sse_http_responsehelper to replace four copies of the inlineHttpResponse-capturing logic, and added byte-body capture support. - Updated the
fetch_similar_messagesstub lambda to include themin_similaritykeyword argument. - Renamed the test job identifier from
anothertosmokein the quantum integration parametrized test and its assertions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_function_app_endpoints.py | Consolidates duplicated SSE capture logic into a helper and aligns a stub signature with the updated API. |
| tests/test_quantum_integration.py | Renames the test job name to smoke for clearer test intent. |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/test_function_app_endpoints.py" line_range="550" />
<code_context>
+ def _fake_similar(query_emb, top_k=5, session_id=None, min_similarity=0.0):
</code_context>
<issue_to_address>
**suggestion (testing):** Assert on the `min_similarity` argument passed into `fetch_similar_messages` to fully cover the updated signature.
Right now the mock accepts `min_similarity` but the test doesn’t check what value is passed. Capture the received `min_similarity` in `captured` (e.g., `captured['min_similarity'] = min_similarity`) and assert on it so the test explicitly verifies the intended default/configured value and guards against future signature drift.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| monkeypatch.setattr(app_module.func, "HttpResponse", | ||
| _capturing_HttpResponse) | ||
| _capture_sse_http_response(monkeypatch, app_module, captured) |
There was a problem hiding this comment.
suggestion (testing): Assert on the min_similarity argument passed into fetch_similar_messages to fully cover the updated signature.
Right now the mock accepts min_similarity but the test doesn’t check what value is passed. Capture the received min_similarity in captured (e.g., captured['min_similarity'] = min_similarity) and assert on it so the test explicitly verifies the intended default/configured value and guards against future signature drift.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_4170bb7a-204c-45b6-b3bf-dbb7c2d94054) |
Summary
Hourly repo health automation cycle (2026-06-21 02:02 UTC) failed pre-commit due to 6 unit test regressions. This PR fixes the test drift and restores a green health cycle.
Changes
_capture_sse_http_responsehelper to capture materialized SSE byte bodies from_sse_response(not just generators)fetch_similar_messagesmock in chat stream tests to acceptmin_similaritykwargsmokejob name intests/test_quantum_integration.py(replacing invalidanother)Verification
.venv/bin/python -m pyteston affected tests: 6 passedPYTHON_BIN=.venv/bin/python scripts/repo_health_automation.py --once --repair-status --refresh-stale-status --run-agents --continue-on-fail— all steps passed (2747 unit tests, integration gate, agents)Summary by Sourcery
Align SSE chat/AGI streaming tests and quantum integration tests with updated APIs to restore passing test suite.
Bug Fixes:
Tests:
Note
Low Risk
Test-only refactors and fixture updates; no runtime behavior in application code is modified.
Overview
Restores failing unit tests after API and validation drift, with no production code changes.
SSE streaming tests gain a shared
_capture_sse_http_responsehelper that records SSE payloads whetherHttpResponseis built from a generator or pre-materialized bytes (e.g. guardrail-blocked streams). Chat/AGI stream tests that duplicated inlineHttpResponsepatches now call this helper.Chat stream mocks for
fetch_similar_messagesaccept themin_similaritykeyword thatfunction_appnow passes when injecting memory.Quantum integration autorun tests use the whitelisted job name
smokeinstead ofanotherin fixtures and assertions.Reviewed by Cursor Bugbot for commit eb3f478. Bugbot is set up for automated code reviews on this repo. Configure here.